package com.bosicen.crm.service.sysmanage;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import com.bosicen.crm.dao.entity.Company;
import com.bosicen.crm.dao.sysmanage.CompanyDao;
import com.bosicen.crm.tools.Page;

import org.springframework.transaction.annotation.Transactional;
/**
 * 企业信息
 * @author tigerlei
 *
 */
@Service("companyService")
public class CompanyServiceImpl {
	@Autowired
	private CompanyDao companyDao;

	/****
	 * 查询列表
	 * 
	 * @param companyid
	 * @return
	 */
	public List<Company> findCompanyList() {
		List<Company> list = null;
		try {
			list = this.companyDao.findCompanyList();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return list;
	}

	/****
	 * 查询列表
	 * 
	 * @param companyid
	 * @return
	 */
	public Page findCompany4Page(Page page,Company company) {
		return this.companyDao.findCompany4Page(page,company);
	}
	/***
	 * 新增/修改
	 * 
	 * @param p
	 */
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public boolean saveOrUpdateCompany(Company p) {
		try {
			 this.companyDao.saveOrUpdate(p);
		} catch (Exception ex) {
			ex.printStackTrace();
			return false;
		}
		return true;
	}

	/****
	 * 按ID查询
	 * 
	 * @param companyid
	 * @return
	 */
	public Company findCompanyById(int id) {
		Company company = null;
		try {
			company = this.companyDao.findCompanyById(id);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return company;
	}

	/****
	 * 删除 
	 * 
	 * @param p
	 */
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public boolean delCompany(Company p) {
		try {
			this.companyDao.delCompany(p);
		} catch (Exception ex) {
			ex.printStackTrace();
			return false;
		}
		return true;
	}
	
	

}
